import { Ionicons } from '@expo/vector-icons'; import { useLocalSearchParams, useRouter } from 'expo-router'; import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native'; import type { ComponentProps } from 'react'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useGrowthData } from '../../src/hooks'; import { LoadingState, ErrorState, EmptyState } from '../../src/components/StateView'; import { articleThumbnailColors, colors } from '../../src/theme'; import { formatViews } from '../../src/utils'; type IconName = ComponentProps['name']; /* ===================== 顶部导航 ===================== */ function Header({ onBack }: { onBack: () => void }) { return ( 职场干货 ); } /* ===================== 页面 ===================== */ export default function ArticleScreen() { const router = useRouter(); const { id } = useLocalSearchParams<{ id: string }>(); const { articles, loading, error, refresh } = useGrowthData(); const article = articles.find((a) => a.id === id); return (
router.back()} /> {loading ? ( ) : error ? ( ) : !article ? ( ) : ( {article.title} {article.tag} {formatViews(article.views)}阅读 {article.content} )} ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: colors.pageBg, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: 8, height: 48, backgroundColor: colors.white, borderBottomWidth: 1, borderBottomColor: colors.borderLight, }, headerBtn: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', }, headerTitle: { fontSize: 17, fontWeight: '700', color: colors.textPrimary, }, scroll: { flex: 1, }, content: { padding: 16, paddingBottom: 24, }, thumb: { width: 72, height: 72, borderRadius: 16, alignItems: 'center', justifyContent: 'center', marginBottom: 14, }, title: { fontSize: 20, fontWeight: '700', color: colors.textPrimary, lineHeight: 28, }, meta: { flexDirection: 'row', alignItems: 'center', marginTop: 10, marginBottom: 16, }, tag: { fontSize: 11, color: colors.primaryText, backgroundColor: colors.primaryLight, paddingHorizontal: 8, paddingVertical: 2, borderRadius: 8, overflow: 'hidden', marginRight: 10, }, views: { fontSize: 12, color: colors.textHint, }, body: { fontSize: 14, lineHeight: 24, color: colors.textSecondary, }, });